#ifndef TERRAIN_EX_H
#define TERRAIN_EX_H
#include <Terrain/OgreTerrain.h>
#include <Terrain/OgreTerrainGroup.h>
#include <Terrain/OgreTerrainQuadTreeNode.h>
#include <Terrain/OgreTerrainMaterialGeneratorA.h>



#include "AdvancedOgreFramework.h"
using namespace Ogre;
using namespace OgreBites;

class TerrainEx
{
protected:
	Ogre::TerrainGlobalOptions*				m_pTerrainGlobals;
	Ogre::TerrainGroup*						m_pTerrainGroup;
	Ogre::String							m_ImagePath;

	Ogre::Light*							m_plight;
	Ogre::Camera*							m_pCamera;
	Ogre::SceneManager*						m_pSceneMgr;

private:
	float									m_TerrainHightScale;
	size_t									m_MapLayer;
	float									m_terrainWoldSize;
	float									m_terrainVertex;
	long									m_LevelHor;
	long									m_LevelVer;

	ShadowCameraSetupPtr					mPSSMSetup;

public:
	TerrainEx(Ogre::SceneManager* msceneMgr, Ogre::Camera* cam, Ogre::Light* light);
	~TerrainEx();
	bool defineTerrain();
	void initBlendMaps(Ogre::Terrain* terrain);
	void configureTerrainDefaults();
	void buildTerrain();
	void destoryTerrain();
	Ogre::TerrainGroup*	getTerrainGroup();
	void setHightImagePath(Ogre::String path);
	void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img);
	void configureShadows(bool enabled, bool depthShadows);

	void setTerrainPosition(const Ogre::Vector3& pos)
	{
		m_pTerrainGroup->setOrigin(pos);
	}

};
#endif